package JAVA300.第十一章多线程;

public class thread_05_web12306 implements Runnable{

    private int tickets = 100;
    @Override
    public void run() {

        while (true){
            if (tickets<0){
                break;
            }

            //如果有网络延迟等存在并发线程安全的情况

            System.out.println(Thread.currentThread().getName()+"--"+tickets--);//获取正在运行线程的名字
        }

    }

    public static void main(String[] args) {
        //一份资源
        thread_05_web12306 tic = new thread_05_web12306();
        new Thread(tic,"thread1").start();
        new Thread(tic,"thread2").start();
        new Thread(tic,"thread3").start();
    }
}
